package com.datseek.iot.rule.manager.generator;

import com.dataseek.iot.core.util.DateUtil;
import com.dataseek.iot.mysql.entity.ActivityRule;
import com.datseek.iot.rule.manager.Handler.FactHandler;
import com.datseek.iot.rule.manager.entity.RuleDTO;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author cc
 * @Title: 规则生成器
 * @Description: 规则生成器
 * @date 2021/9/175:50 下午
 * @since 1.0
 */
@Slf4j
public class RuleGenerator {

    public void generateRules(List<RuleDTO> ruleDTOS){
        List<String> rules = new ArrayList<>();
        for(RuleDTO rule: ruleDTOS){
//            String drlS
        }
    }


    Map<String, Object> prepareData(RuleDTO ruleDTO){
        Map<String, Object> data = new HashMap<>();
        ActivityRule rule = ruleDTO.getRule();
        data.put("ruleCode", ruleDTO.getRule());
        data.put("beginTime", DateUtil.dateToStringFormat(ruleDTO.getBeginTime(), "dd-MMM-yyyy"));
        data.put("endTime",  DateUtil.dateToStringFormat(ruleDTO.getEndTime(), "dd-MMM-yyyy"));
        data.put("eventType", FactHandler.getFactClassByEvent(rule.getEvent()).getName());
        data.put("rule", rule.getRuleValue());
        data.put("awardType", rule.getAwardType());
        return data;
    }
}
